<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
        
    <xsl:template match="/">
        <tracks>
            <xsl:apply-templates select="/plist/dict/dict[preceding-sibling::key[1]='Tracks']/dict" mode="track"/>
        </tracks>
	<playlists>
	    <xsl:apply-templates select="/plist/dict/array[preceding-sibling::key[1]='Playlists']/dict" mode="playlist"/>
	</playlists>
    </xsl:template>
    
    <xsl:template match="dict" mode="track">
        <track>
            <xsl:apply-templates select="key" mode="track"/>
        </track>
    </xsl:template>
    
    <xsl:template match="key" mode="track">
        <xsl:element name="{translate(text(), ' ', '_')}">
            <xsl:value-of select="following-sibling::node()[1]"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="dict" mode="playlist">
        <playlist>
            <xsl:apply-templates select="key" mode="playlist"/>
	    <xsl:apply-templates select="./array/dict/key" mode="playlisttrack" />
        </playlist>
    </xsl:template>

    <xsl:template match="key" mode="playlist">
        <xsl:element name="{translate(text(), ' ', '_')}">
            <xsl:value-of select="following-sibling::node()[1]"/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="key" mode="playlisttrack">
        <xsl:element name="{translate(text(), ' ', '_')}">
            <xsl:value-of select="following-sibling::node()[1]"/>
        </xsl:element>
    </xsl:template>


</xsl:stylesheet>